package com.wushijia.test;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.ParseException;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.UUID;

public class BasicLearnTest01 {

  private static DecimalFormat df = new DecimalFormat("0");
  private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  private static DecimalFormat nf = new DecimalFormat("0.00");

  public static void main(String[] args) {

    System.out.println(UUID.randomUUID().toString().toUpperCase().replaceAll("-", ""));
    System.out.println(new BigDecimal("0").equals(BigDecimal.ZERO));
    System.out.println(Integer.toBinaryString(-2));
    System.out.println(Integer.toBinaryString(-2>>>3));
    System.out.println(-2>>>1);//10000010
    BigDecimal changeFee = new BigDecimal("71").multiply(new BigDecimal("280"));
    System.out.println(changeFee);
    System.out.println("==========================集合，数组，字符串之间的转换========================");
    List<String> stringList = new ArrayList<>();
    stringList.add("d");
    stringList.add("e");
    stringList.add("f");
    stringList.removeIf("e"::equals);
    int[] nums = new int[]{1, 2, 3, 4};
    System.out.println(Arrays.toString(nums));
    System.out.println(String.join("-", "a", "b", "c"));
    System.out.println(String.join("-", stringList));
    System.out.println(Arrays.toString(stringList.toArray(new String[stringList.size()])));
    System.out.println(Arrays.toString("sedwr".toCharArray()));
    ArrayList<Object> list = new ArrayList<>(Arrays.asList(nums));
    System.out.println("===========================日期处理===============================");
    System.out.println(DateFormat.getDateInstance(DateFormat.LONG).format(new Date()));
    LocalDateTime localDateTime = LocalDateTime.now();
    LocalDate localDate = localDateTime.toLocalDate().plus(1, ChronoUnit.DAYS);
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    try {
      System.out.println(sdf.parse(localDate.toString()));
      //ParsePosition???
      System.out.println(sdf.parse(sdf.format(new Date()),new ParsePosition(3)));
    } catch (ParseException e) {
      e.printStackTrace();
    }
  }
}
